﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DVO;

public partial class ListWorking : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (IsPostBack == false)
        {
            LoadData();
        }
    }

    #region "LoadData"
    private void LoadData()
    {
        string id = txtWorkId.Text.Trim();
        string workname = txtWorkName.Text.Trim();
        BLL_Working ObjBLL = new BLL_Working();
        List<ins_Working_SearchResult> Objlist = new List<ins_Working_SearchResult>();
        try
        {
            if (HttpContext.Current.Session["r"].ToString() == "4" || HttpContext.Current.Session["r"].ToString() == "3")
            {
                Objlist = ObjBLL.Working_Search(id,workname).ToList();
            }
            else
            {
                Objlist = ObjBLL.Working_Search(id,workname).ToList().Where(x => x.Author == Page.User.Identity.Name).ToList();
            }
        }
        catch (Exception )
        {
            Response.Redirect("Login.aspx");
        }
       
        grid.DataSource = Objlist;
        grid.DataBind();
    }
    #endregion

    public string GetStatus(string Status)
    {
        if (Status == "0")
            return "Mới";
        else if (Status == "1")
            return "Đang xử lý";
        else if (Status == "2")
            return "Hoàn thành";
        return "";
    }
    protected void grid_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        grid.PageIndex = e.NewPageIndex;
        LoadData();
    }

    public string hideSendDocument(string Status, string id)
    {

        if (Status != "2")
            return "<a" + " href='UploadDocument.aspx?Id=" + id + "'  onmouseout='UnTip()' onmouseover=\"Tip('GỬI TÀI LIỆU ĐI KIỂM DUYỆT')\">Gửi Tài Liệu</a>";
        else
            return "";
    }
    protected void btnTimKiem_Click(object sender, EventArgs e)
    {
        LoadData();
    }
}